home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / pdcurs21.zip / PRIVATE.ZIP / _SYSGETC.C < prev    next >
Text File  |  1992-11-21  |  2KB  |  67 lines

  1. #define        CURSES_LIBRARY  1
  2. #include <curses.h>
  3.  
  4. #ifndef        NDEBUG
  5. char *rcsid__sysgetc = "$Header: c:/curses/private/RCS/_sysgetc.c%v 2.0 1992/11/15 03:24:39 MH Rel $";
  6. #endif
  7.  
  8.  
  9.  
  10.  
  11. /*man-start*********************************************************************
  12.  
  13.   PDC_sysgetch()       - Return a character using default system routines.
  14.  
  15.   PDCurses Description:
  16.        This is a private PDCurses function.
  17.  
  18.        Gets a character without normal ^S, ^Q, ^P and ^C interpretation
  19.        and returns it.  If keypad mode is active for the designated
  20.        window, function key translation will be performed. Otherwise,
  21.        function keys are ignored. If nodelay mode is active in the
  22.        window, then sysgetch() returns -1 if no character is
  23.        available.
  24.  
  25.   PDCurses Return Value:
  26.        This function returns OK upon success otherwise ERR is returned.
  27.  
  28.   PDCurses Errors:
  29.        No errors are defined for this routine.
  30.  
  31.   Portability:
  32.        PDCurses        int     PDC_sysgetch( void );
  33.  
  34. **man-end**********************************************************************/
  35.  
  36. int    PDC_sysgetch(void)
  37. {
  38. extern WINDOW* _getch_win_;
  39. /* extern      WINDOW* w;*/   /* w defined in wgetch() as static - _getch_win_ */
  40.                         /* is the same window - all references to w changed*/
  41.                         /* to _getch_win_ - marked with @@ */
  42.  
  43.        signed  c;
  44.  
  45.        if (_getch_win_ == (WINDOW *)NULL)  /* @@ */
  46.                return (-1);
  47.  
  48.        if (_getch_win_->_nodelay && !typeahead(stdin))
  49.                return (-1);
  50.  
  51.        while (1)
  52.        {
  53.                c = PDC_get_bios_key();
  54. #if    defined (DOS) || defined (OS2)
  55.                /*
  56.                 * Return the key if it is not a special key.
  57.                 */
  58.                if (c & A_CHARTEXT)
  59.                        return (c & A_CHARTEXT);
  60. #endif
  61.                if ((c = PDC_validchar(c)) >= 0)
  62.                {
  63.                        return (c);             /* get & check next char */
  64.                }
  65.        }
  66. }
  67.